package com.dog.framework.email.config;

import com.dog.framework.email.service.MailService;
import com.dog.framework.email.service.impl.MailServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({MailProperties.class})
public class EmailAutoConfiguration {

    @Bean
    @ConditionalOnProperty(prefix = "spring.mail", name = "protocol", havingValue = "smtp", matchIfMissing = false)
    public MailService mailService() {
        return new MailServiceImpl();
    }
}
